#include "stdafx.h"
#include "StringUtils.h"

bool readCmdLine_option(const char* cmdLine, char optionCh, char* outBuf)
{
	if (!cmdLine) return false;

	char _optCh = isupper(optionCh) ? tolower(optionCh) : toupper(optionCh);
	
	const char* pCmdLine = cmdLine;
	char* pOutBuf = outBuf;
	const char* slash;
	while (1)
	{
		slash = strchr(pCmdLine, '/');
		if (slash) {
			pCmdLine = slash + 1;
			if (*pCmdLine == optionCh || *pCmdLine == _optCh) {
				pCmdLine++;
				if (outBuf) {
					while (*pCmdLine && *pCmdLine != ' ')
					{
						*pOutBuf = *pCmdLine;
						pOutBuf++;
						pCmdLine++;
					}
					*pOutBuf = 0;
				}
				return true;
			}
		}
		else return false;
	}
}
